#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repp(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a-1;i>=b;--i)
#define pper(i,a,b) for(int i=a;i>=b;--i)
#define pii pair<int,int>
#define m_p make_pair
#define fi first
#define se second
#define pb push_back
#define inf 0x7fffffff
#define inff 0x7fffffffffffffff
#define all(x) x.begin(),x.end()
#define int ll
const int mod = 998244353;
inline int rd(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-')f=-f;
		ch=getchar();
	}
	while(isdigit(ch)){
		x=x*10+(ch^48);
		ch=getchar();
	}
	return x*f;
}
ll pw(ll x,int d){
	ll t=1;
	for(;d;d>>=1,x=x*x%mod)if(d&1)t=t*x%mod;
	return t;
}
#define MAX 1000005
int pre[MAX];
pii seg[MAX];
bool vis[MAX];
int sm(int l,int r){
	if(l==0)return pre[r];
	return pre[r]-pre[l-1];
}
signed main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	int T = rd();
	while(T--){
		int n = rd();
		int m = rd();
		int L = rd();
		int V = rd();
		memset(pre,0,sizeof(pre));
		memset(vis,0,sizeof(vis));
		int segcnt = 0;
		repp(i,1,n){
			int d = rd();
			int v = rd();
			int a = rd();
			// cout<<d<<' '<<v<<' '<<a<<endl;
			if(a>0){
				if(v*v+2ll*a*(L-d)<=V*V)continue ;
				int lp=-1;
				if(v>V){
					lp = d;
				}else{
					lp = d+(V*V-v*v)/(a*2)+1;
				}
				int rp=L;
				assert(lp>=0);
				seg[++segcnt] = {lp,rp};
				assert(lp<=rp);
			}else if(a==0){
				if(v>V){
					int lp=d,rp=L;
					seg[++segcnt] = {lp,rp};
				}else{
					continue ;
				}
			}else{
				if(v<=V)continue ;
				a = -a;
				int lp=d;
				int rp = min(L,(v*v-V*V-1)/(a*2)+d);
				assert(lp>=0);
				assert(lp<=rp);
				seg[++segcnt] = {lp,rp};
			}
		}
		// repp(i,1,segcnt){
		// 	cout<<seg[i].fi<<','<<seg[i].se<<endl;
		// }
		repp(i,1,segcnt){
			assert(seg[i].fi>=0);
		}
		repp(i,1,m){
			int p = rd();
			pre[p]++;
			vis[p] = 1;
		}
		repp(i,1,L)pre[i] += pre[i-1];
		int rlt = 0;
		int mcnt = 0;
		vector<pii> segv;
		repp(i,1,segcnt){
			if(sm(seg[i].fi,seg[i].se)){
				rlt++;
				segv.pb({seg[i].fi,seg[i].se});
			}
		}
		sort(all(segv),[&](pii x,pii y){return x.se<y.se;});
		int lstp = -1;
		for(auto itm : segv){
			int l=itm.fi,r=itm.se;
			// cout<<" :: "<<l<<' '<<r<<endl;
			if(lstp<l){
				pper(x,r,0){
					if(vis[x]){
						lstp = x;
						mcnt++;
						break;
					}
				}
				// if(lstp<l){
				// 	assert(false);
				// }
			}
		}
		cout<<rlt<<' '<<m-mcnt<<endl;
		// return 0;
	}
	return 0;
}
/*
g++ detect.cpp -o detect -g -std=c++14 -Wall -Wshadow -fsanitize=address,undefined && ./detect < detect1.in 
*/